# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gc

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=7.4.2
pkgrel=1
pkgdesc="A garbage collector for C and C++ (mingw-w64)"
arch=('any')
url="http://www.hboehm.info/gc"
license=("GPL")
makedepends=(${MINGW_PACKAGE_PREFIX}-gcc ${MINGW_PACKAGE_PREFIX}-pkg-config)
depends=(${MINGW_PACKAGE_PREFIX}-gcc-libs ${MINGW_PACKAGE_PREFIX}-libatomic_ops)
options=('staticlibs' 'strip')
source=("$url/gc_source/${_realname}-${pkgver}.tar.gz"
        0001-winpthreads.mingw.patch
        0003-move-docs.all.patch)
md5sums=('12c05fd2811d989341d8c6d81f66af87'
         '97223c965b5e0c61d9bbf2710b44ddb6'
         '9b9691bc94fe70b6dcb144f1be49145a')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-winpthreads.mingw.patch
  patch -p1 -i ${srcdir}/0003-move-docs.all.patch
  
  ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  export lt_cv_deplibs_check_method='pass_all'
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-threads=posix \
    --disable-dependency-tracking \
    --enable-large-config \
    --enable-cplusplus
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
}
